/*
 * Copyright 2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mx.ymate.security.base.model;

import net.ymate.platform.core.beans.annotation.PropertyState;
import net.ymate.platform.core.persistence.IShardingable;
import net.ymate.platform.core.persistence.annotation.*;
import net.ymate.platform.persistence.jdbc.IDatabase;
import net.ymate.platform.persistence.jdbc.IDatabaseConnectionHolder;
import net.ymate.platform.persistence.jdbc.query.AbstractFieldConditionBuilder;
import net.ymate.platform.persistence.jdbc.query.FieldCondition;
import net.ymate.platform.persistence.jdbc.query.Query;
import net.ymate.platform.persistence.jdbc.support.BaseEntity;

/**
 * SecurityRole generated By EntityMojo on 2022/07/03 14:13:14
 *
 * @author YMP (https://www.ymate.net/)
 */
@Entity(SecurityRole.TABLE_NAME)
@Comment("角色表")
public class SecurityRole extends BaseEntity<SecurityRole, String> {

    private static final long serialVersionUID = 1L;

    @Id
    @Property(name = FIELDS.ID, nullable = false, length = 32)
    @Comment("id")
    @PropertyState(propertyName = FIELDS.ID)
    private String id;

    
    @Property(name = FIELDS.RESOURCE_ID, nullable = false, length = 32)
    @Comment("资源id 默认和客户端一致")
    @PropertyState(propertyName = FIELDS.RESOURCE_ID)
    private String resourceId;

    
    @Property(name = FIELDS.CLIENT, nullable = false, length = 100)
    @Comment("客户端")
    @PropertyState(propertyName = FIELDS.CLIENT)
    private String client;

    
    @Property(name = FIELDS.NAME, nullable = false, length = 100)
    @Comment("名称")
    @PropertyState(propertyName = FIELDS.NAME)
    private String name;

    
    @Property(name = FIELDS.REMARK, length = 255)
    @Comment("备注")
    @PropertyState(propertyName = FIELDS.REMARK)
    private String remark;

    
    @Property(name = FIELDS.CREATE_USER, nullable = false, length = 32)
    @Comment("创建人")
    @PropertyState(propertyName = FIELDS.CREATE_USER)
    private String createUser;

    
    @Property(name = FIELDS.CREATE_TIME, nullable = false, length = 19)
    @Default("0")
    @Comment("创建时间")
    @PropertyState(propertyName = FIELDS.CREATE_TIME)
    private Long createTime;

    
    @Property(name = FIELDS.LAST_MODIFY_USER, nullable = false, length = 32)
    @Comment("最后更新人")
    @PropertyState(propertyName = FIELDS.LAST_MODIFY_USER)
    private String lastModifyUser;

    
    @Property(name = FIELDS.LAST_MODIFY_TIME, nullable = false, length = 19)
    @Default("0")
    @Comment("最后更新时间")
    @PropertyState(propertyName = FIELDS.LAST_MODIFY_TIME)
    private Long lastModifyTime;


    public SecurityRole() {
    }

    public SecurityRole(IDatabase dbOwner) {
        super(dbOwner);
    }

    public SecurityRole(String id, String resourceId, String client, String name, String createUser, Long createTime, String lastModifyUser, Long lastModifyTime) {
        this.id = id;
        this.resourceId = resourceId;
        this.client = client;
        this.name = name;
        this.createUser = createUser;
        this.createTime = createTime;
        this.lastModifyUser = lastModifyUser;
        this.lastModifyTime = lastModifyTime;
    }

        public SecurityRole(IDatabase dbOwner, String id, String resourceId, String client, String name, String createUser, Long createTime, String lastModifyUser, Long lastModifyTime) {
            super(dbOwner);
            this.id = id;
            this.resourceId = resourceId;
            this.client = client;
            this.name = name;
            this.createUser = createUser;
            this.createTime = createTime;
            this.lastModifyUser = lastModifyUser;
            this.lastModifyTime = lastModifyTime;
        }

    public SecurityRole(String id, String resourceId, String client, String name, String remark, String createUser, Long createTime, String lastModifyUser, Long lastModifyTime) {
        this.id = id;
        this.resourceId = resourceId;
        this.client = client;
        this.name = name;
        this.remark = remark;
        this.createUser = createUser;
        this.createTime = createTime;
        this.lastModifyUser = lastModifyUser;
        this.lastModifyTime = lastModifyTime;
    }

    public SecurityRole(IDatabase dbOwner, String id, String resourceId, String client, String name, String remark, String createUser, Long createTime, String lastModifyUser, Long lastModifyTime) {
        super(dbOwner);
        this.id = id;
        this.resourceId = resourceId;
        this.client = client;
        this.name = name;
        this.remark = remark;
        this.createUser = createUser;
        this.createTime = createTime;
        this.lastModifyUser = lastModifyUser;
        this.lastModifyTime = lastModifyTime;
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public String getLastModifyUser() {
        return lastModifyUser;
    }

    public void setLastModifyUser(String lastModifyUser) {
        this.lastModifyUser = lastModifyUser;
    }

    public Long getLastModifyTime() {
        return lastModifyTime;
    }

    public void setLastModifyTime(Long lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }


    public Builder bind() {
        return new Builder(this);
    }

    public static Builder builder() {
        return new Builder();
    }

        public static Builder builder(IDatabase dbOwner) {
            return new Builder(dbOwner);
        }

    public static class Builder {

        private final SecurityRole targetEntity;

        public Builder() {
            targetEntity = new SecurityRole();
        }

        public Builder(IDatabase dbOwner) {
            targetEntity = new SecurityRole(dbOwner);
        }

        public Builder(SecurityRole targetEntity) {
            this.targetEntity = targetEntity;
        }

        public SecurityRole build() {
            return targetEntity;
        }

        public IDatabaseConnectionHolder connectionHolder() {
            return targetEntity.getConnectionHolder();
        }

        public Builder connectionHolder(IDatabaseConnectionHolder connectionHolder) {
            targetEntity.setConnectionHolder(connectionHolder);
            return this;
        }

        public IDatabase dbOwner() {
            return targetEntity.getDbOwner();
        }

        public Builder dbOwner(IDatabase dbOwner) {
            targetEntity.setDbOwner(dbOwner);
            return this;
        }

        public String dataSourceName() {
            return targetEntity.getDataSourceName();
        }

        public Builder dataSourceName(String dataSourceName) {
            targetEntity.setDataSourceName(dataSourceName);
            return this;
        }

        public IShardingable shardingable() {
            return targetEntity.getShardingable();
        }

        public Builder shardingable(IShardingable shardingable) {
            targetEntity.setShardingable(shardingable);
            return this;
        }


        public String id() {
            return targetEntity.getId();
        }

        public Builder id(String id) {
            targetEntity.setId(id);
            return this;
        }

        public String resourceId() {
            return targetEntity.getResourceId();
        }

        public Builder resourceId(String resourceId) {
            targetEntity.setResourceId(resourceId);
            return this;
        }

        public String client() {
            return targetEntity.getClient();
        }

        public Builder client(String client) {
            targetEntity.setClient(client);
            return this;
        }

        public String name() {
            return targetEntity.getName();
        }

        public Builder name(String name) {
            targetEntity.setName(name);
            return this;
        }

        public String remark() {
            return targetEntity.getRemark();
        }

        public Builder remark(String remark) {
            targetEntity.setRemark(remark);
            return this;
        }

        public String createUser() {
            return targetEntity.getCreateUser();
        }

        public Builder createUser(String createUser) {
            targetEntity.setCreateUser(createUser);
            return this;
        }

        public Long createTime() {
            return targetEntity.getCreateTime();
        }

        public Builder createTime(Long createTime) {
            targetEntity.setCreateTime(createTime);
            return this;
        }

        public String lastModifyUser() {
            return targetEntity.getLastModifyUser();
        }

        public Builder lastModifyUser(String lastModifyUser) {
            targetEntity.setLastModifyUser(lastModifyUser);
            return this;
        }

        public Long lastModifyTime() {
            return targetEntity.getLastModifyTime();
        }

        public Builder lastModifyTime(Long lastModifyTime) {
            targetEntity.setLastModifyTime(lastModifyTime);
            return this;
        }
    }

    public interface FIELDS {
        String ID = "id";
        String RESOURCE_ID = "resource_id";
        String CLIENT = "client";
        String NAME = "name";
        String REMARK = "remark";
        String CREATE_USER = "create_user";
        String CREATE_TIME = "create_time";
        String LAST_MODIFY_USER = "last_modify_user";
        String LAST_MODIFY_TIME = "last_modify_time";
    }

    public static final String TABLE_NAME = "security_role";

    public static FieldConditionBuilder conditionBuilder() {
        return new FieldConditionBuilder();
    }

    public static FieldConditionBuilder conditionBuilder(String prefix) {
        return new FieldConditionBuilder(prefix);
    }

    public static FieldConditionBuilder conditionBuilder(Query<?> query) {
        return conditionBuilder(query, null);
    }

    public static FieldConditionBuilder conditionBuilder(Query<?> query, String prefix) {
        return new FieldConditionBuilder(query.owner(), query.dataSourceName(), prefix);
    }

    public static FieldConditionBuilder conditionBuilder(SecurityRole entity) {
        return conditionBuilder(entity, null);
    }

    public static FieldConditionBuilder conditionBuilder(SecurityRole entity, String prefix) {
        return new FieldConditionBuilder(entity.doGetSafeOwner(), entity.getDataSourceName(), prefix);
    }

    public static FieldConditionBuilder conditionBuilder(IDatabase owner, String prefix) {
        return new FieldConditionBuilder(owner, prefix);
    }

    public static FieldConditionBuilder conditionBuilder(IDatabase owner, String dataSourceName, String prefix) {
        return new FieldConditionBuilder(owner, dataSourceName, prefix);
    }

    public static class FieldConditionBuilder extends AbstractFieldConditionBuilder {

        public FieldConditionBuilder() {
            super(null, null, null);
        }

        public FieldConditionBuilder(String prefix) {
            super(null, null, prefix);
        }

        public FieldConditionBuilder(Query<?> query) {
            super(query.owner(), null, null);
        }

        public FieldConditionBuilder(Query<?> query, String prefix) {
            super(query.owner(), query.dataSourceName(), prefix);
        }

        public FieldConditionBuilder(IDatabase owner) {
            super(owner, null, null);
        }

        public FieldConditionBuilder(IDatabase owner, String prefix) {
            super(owner, null, prefix);
        }

        public FieldConditionBuilder(IDatabase owner, String dataSourceName, String prefix) {
            super(owner, dataSourceName, prefix);
        }

        public FieldCondition id() {
            return createFieldCondition(FIELDS.ID);
        }

        public FieldCondition resourceId() {
            return createFieldCondition(FIELDS.RESOURCE_ID);
        }

        public FieldCondition client() {
            return createFieldCondition(FIELDS.CLIENT);
        }

        public FieldCondition name() {
            return createFieldCondition(FIELDS.NAME);
        }

        public FieldCondition remark() {
            return createFieldCondition(FIELDS.REMARK);
        }

        public FieldCondition createUser() {
            return createFieldCondition(FIELDS.CREATE_USER);
        }

        public FieldCondition createTime() {
            return createFieldCondition(FIELDS.CREATE_TIME);
        }

        public FieldCondition lastModifyUser() {
            return createFieldCondition(FIELDS.LAST_MODIFY_USER);
        }

        public FieldCondition lastModifyTime() {
            return createFieldCondition(FIELDS.LAST_MODIFY_TIME);
        }
    }
}
